<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<jsp:include page="/WEB-INF/views/commons/center_top.jsp"/>
<style>
	h1{text-align: left;}
	.widget-body{
		overflow-y: scroll;
		min-height: 500px;
		max-height: 700px;
	}
	.currentTD{
		background: #c7d3a9;
	}
</style>
<input type="hidden" id="id" value="${role.id}"/>
<div class="col-sm-6">
	<div class="widget-box">
		<div class="widget-header header-color-blue">
			<span>人员类型列表</span>
			<div class="widget-toolbar no-border">
				<div class="btn-group">
					<button class="btn btn-${btn_color} btn-sm" id="jobsSave">
						<i class="icon-save bigger-150"></i>
						<s:message code="save"/>
					</button>
				</div>
			</div>
		</div>
		<div class="widget-body">
			<div class="table-responsive">
				<table id="jobs-table" class="table table-striped table-bordered table-hover">
					<thead>
						<tr>
							<th class="center">
								<label><input type="checkbox" class="ace"><span class="lbl"></span></label>
							</th>
							<th>人员类型</th>
						</tr>
					</thead>
					<tbody>
						<c:forEach items="${jobsList}" var="job">
							<c:set var="hasJob" value="0"></c:set>
							<c:forEach items="${role.jobs}" var="rj">
								<c:if test="${job.id == rj.id}">
									<c:set var="hasJob" value="1"></c:set>
								</c:if>
							</c:forEach>
							<tr>
								<td class="center">
									<label><input value="${job.id}" <c:if test="${hasJob==1}">checked="checked"</c:if> type="checkbox" class="ace"><span class="lbl"></span></label>
								</td>
								<td class="job-td" data-id="${job.id}">${job.name}</td>
							</tr>
						</c:forEach>
					</tbody>
				</table>
			</div>
		</div>
	</div>
</div>

<div class="col-sm-6">
	<div class="widget-box">
		<div class="widget-header header-color-blue">
			<span>用户列表</span>
			<div class="widget-toolbar no-border">
				<div class="btn-group">
					<button class="btn btn-${btn_color} btn-sm" id="userSave">
						<i class="icon-save bigger-150"></i>
						<s:message code="save"/>
					</button>
				</div>
			</div>
		</div>
		<div class="widget-body">
			<div class="table-responsive">
				<table id="user-table" class="table table-striped table-bordered table-hover">
					<thead>
						<tr>
							<th class="center">
								<label><input type="checkbox" class="ace"><span class="lbl"></span></label>
							</th>
							<th>用户</th>
							<td>人员类型</td>
						</tr>
					</thead>
					<tbody>
						<c:forEach items="${users}" var="user">
							<c:set var="hasUser" value="0"></c:set>
							<c:forEach items="${role.users}" var="ru">
								<c:if test="${user.id == ru.id}">
									<c:set var="hasUser" value="1"></c:set>
								</c:if>
							</c:forEach>
							<tr>
								<td class="center">
									<label><input value="${user.id}" <c:if test="${hasUser==1}">checked="checked"</c:if> type="checkbox" class="ace"><span class="lbl"></span></label>
								</td>
								<td>${user.realname}</td>
								<td>${user.jobs.name}</td>
							</tr>
						</c:forEach>
					</tbody>
				</table>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript" src="/static/module/system//role/bind.js"></script>
<script type="text/javascript" src="/static/module/commons/public.js"></script>